'''
Created on 22/06/2012

@author: Amy
'''
import unittest

from mock import Mock

from models import Computer, SMSClient

class TestModelComputer(unittest.TestCase):

    def testComputerCanBeOnline(self):
        computer = Computer("Hostname")
        computer.IsOnline = Mock(return_value=True)
        print "Computer Online: ", str(computer.IsOnline())
        self.assertTrue(computer.IsOnline(), "Computer is not online")
    
    def testComputerCanBeOffline(self):
        computer = Computer("Hostname")
        computer.IsOnline = Mock(return_value=False)
        self.assertFalse(computer.IsOnline(), "Computer is not offline")

    def testComputerHasStatus(self):
        computer = Computer("Hostname")
        computer.setStatus("Online")
        self.assertNotEqual(None, computer.getStatus(), "Computer has a Status")
    
    def testComputerHasHostname(self):
        computer = Computer("Hostname")
        self.assertNotEqual(None, computer.getHostName(), "Computer has no hostname")
        
    def testComputerHasListItemIndex(self):
        computer = Computer("Hostname")
        computer.setListIndex(1)
        self.assertIsInstance(computer.getListIndex(), int, "Computer has No index")
        
    def testComputerHasSMSClient(self):
        computer = Computer("Hostname")
        self.assertIsInstance(computer.SMSClient(), SMSClient, "Computer has no SMSClient Object.")

class TestModelSMSClient(unittest.TestCase):
    def testSMSClientHasHostName(self):
        sms = SMSClient("Hostname")
        self.assertTrue(sms.HostName, "Computer has no hostname.")
        
    def testSMSClientCanGetPingResponse(self):
        sms = SMSClient("Hostname")
        self.assertTrue(sms.getPing(), "can't ping host")
        
    def testSMSClientHasCurrentUserFunction(self):
        sms = SMSClient("Hostname")
        self.assertIsNotNone(sms.getCurrentUser(), "Function doesn't return anything")
        
    def testSMSClientHasWMIProvider(self):
        sms = SMSClient("Hostname")
        self.assertIsNotNone(sms.WMI(), "No WMI Object on SMSClient")
    
if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()